# coding: utf-8

from flask import Flask, request
from flask import render_template

import src.core.TextClassfier as TextClassfier

app = Flask(__name__)

# @app.route('/<text>', methods=['GET', 'POST'])
@app.route('/', methods=['GET', 'POST'])
def test():
    print("enter!")
    text = None
    if request.method == "POST":
        text = request.form['text']
    if text:
        text = text.strip()
        type = TextClassfier.classifier(text) + 1
        print(text)
        print("type is ", type)
    else:
        type = -1
        text = ""
    return render_template('classifier.html', type=type, text=text)


@app.route('/hello')
def hello():
    return 'Hello, World!'